# 给你一个整数数组 nums ，设计算法来打乱一个没有重复元素的数组。
#
# 实现 Solution class:
#
# Solution(int[] nums) 使用整数数组 nums 初始化对象
# int[] reset() 重设数组到它的初始状态并返回
# int[] shuffle() 返回数组随机打乱后的结果
import random
from typing import List


class Solution:

    def __init__(self, nums: List[int]):
        self.original = nums[:]  # 复制一份
        self.array = nums

    def reset(self) -> List[int]:
        self.array = self.original[:]  # 还是要复制一份
        return self.array

    def shuffle(self) -> List[int]:
        for i in range(len(self.array)):
            swap_idx = random.randrange(i, len(self.array))
            self.array[i], self.array[swap_idx] = self.array[swap_idx], self.array[i]
        return self.array


# Your Solution object will be instantiated and called as such:
# obj = Solution(nums)
# param_1 = obj.reset()
# param_2 = obj.shuffle()

if __name__ == '__main__':
    sol = Solution([1, 2, 3])
    print(sol.shuffle())
    print(sol.reset())
